import React from 'react'
import '../css/InputBox.css'
import eventEmitter from '../event.js'

class InputBox extends React.Component {
    constructor(props) {
        super(props)
    }



    render() {
        return (
            <div className="input_container">
                <input type="text" ref="input" />
                <button onClick={() => {
                    let value = this.refs.input.value
                    if (value.length == 0) {
                        alert("内容不能为空")
                        return
                    }

                    var date = new Date()
                    var dateStr = `${date.getFullYear()}年${date.getMonth()}月${date.getDate()}日${date.getHours()}时${date.getMinutes()}分`
                    var message = {
                        content:value,
                        date:dateStr
                    }

                    eventEmitter.emit("sendMessageTooBoard",message)
                }}>提交</button>
            </div>
        )
    }
}


export default InputBox